﻿using Iit.Automation.Browsers.Shared;
using OpenQA.Selenium.Chrome;
using OpenQA.Selenium.Interactions;

namespace Iit.Automation.Browsers.Chrome
{
    public class ChromeBrowser : ChromeDriver, IBrowser
    {
        private static ChromeBrowser _instance;
        private string _folderPath;

        private ChromeBrowser(string WebdriverFolderPath)
            : base(WebdriverFolderPath)
        {
            _folderPath = WebdriverFolderPath;
        }

        public static IBrowser GetInstance(string folderPath)
        {
            if (_instance == null)
            {
                _instance = CreateNewInstance(folderPath);
            }

            return _instance;
        }

        private static ChromeBrowser CreateNewInstance(string folderPath)
        {
            return new ChromeBrowser(folderPath);
        }

        public Actions GetAction()
        {
            return new Actions(this);
        }

        public string DriverFolderPath
        {
            get { return _folderPath; }
        }

        public IComponentFactory ComponentFactory { get; set; }
    }
}
